package com.smartwebx.ha.web.admin.module.screen.report;

import java.sql.CallableStatement;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.util.List;

import oracle.jdbc.OracleCallableStatement;

public class TestOBDC {
	public static void main(String[] args) {
		TestOBDC a = new TestOBDC();
		a.getData("{?=call JPTJ('2014-07-01 06:11:00','2014-08-01 04:12:00')}");
	}

	public List<CommonReport> getData(String call){
		Connection conn = null;
		CallableStatement statement = null;
		ResultSet rs = null;
		try {
			ConnUtils connUtils = new ConnUtils();
			conn = connUtils.getConnection();
			statement = conn.prepareCall(call);
			statement.registerOutParameter(1, oracle.jdbc.OracleTypes.CURSOR);
			statement.executeUpdate();
			rs = ((OracleCallableStatement) statement).getCursor(1);
			ResultSetMetaData rsmd = null;
			rsmd = rs.getMetaData();
			int columnCount = rsmd.getColumnCount();
			while(rs.next()){
				System.out.println(rs.getString(1));
				System.out.println(Double.parseDouble(rs.getString(2)));
			}
			
			ConnUtils.free(rs, statement, conn);
		} catch (SQLException e) { 
			ConnUtils.free(rs, statement, conn);
		} catch (NullPointerException n) { 

		} 
		return null; 
	}
}
